package org.finesys.common.dataPermission.dept.config;

import org.finesys.common.dataPermission.dept.rule.DeptDataPermissionRule;
import org.finesys.common.dataPermission.dept.rule.DeptDataPermissionRuleCustomizer;
import org.finesys.common.dataPermission.dept.service.DataPermissionService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;

import java.util.List;

@AutoConfiguration
public class DeptDataPermissionAutoConfiguration {

    @Bean
    public DeptDataPermissionRule deptDataPermissionRule(DataPermissionService dataPermissionService, List<DeptDataPermissionRuleCustomizer> customizerList) {
        //创建数据权限规则
        DeptDataPermissionRule rule = new DeptDataPermissionRule(dataPermissionService);
        //根据配置的自定义规则，补全部门数据权限的表信息
        customizerList.forEach(customizer -> customizer.customize(rule));
        return rule;
    }
}
